﻿Imports System.Data.SqlClient
Imports System.Data
Imports System.Data.OleDb.OleDbConnection
Public Class DataProvider
    Public Shared Function KetNoi() As SqlConnection

        Try
            Dim cm As String = "Data Source=ASUS-PC;Initial Catalog=QuanLyNha;Integrated Security=True"
            Dim cn As SqlConnection = New SqlConnection(cm)
            cn.Open()
            Return cn
        Catch ex As Exception
            MessageBox.Show(" Kết nối dữ liệu không thành công!! Xin vui lòng thử lại!!")
        End Try

    End Function

    Public Shared Function KetNoiExecl(ByVal path As String) As System.Data.OleDb.OleDbConnection

        Try
            Dim cm As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & path & ";Extended Properties=Excel 12.0"
            'Dim cn As SqlConnection = New SqlConnection(cm)
            Dim myconnection As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(cm)
            myconnection.Open()
            Return myconnection
        Catch ex As Exception
            MessageBox.Show(" Dữ liệu kết nối không thành công!! Xin vui lòng thử lại!!")
        End Try

    End Function
End Class
